<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let year = 1986;
        let month = 4;
        let day = 2;

        let now = new Date();
        let year2 = now.getFullYear();
        let month2 = now.getMonth() + 1;
        let day2 = now.getDate();

        let result = year2 - year;
        if (month2 < month) {
            result --;
        } else if (month2 == month && day2 <= day) {
            result --;
        }

        alert("你的年龄：" + result);
    </script>
</body>
</html>